package shapewar.view.indvidul;

import android.graphics.Canvas;
import android.graphics.Color;
import shapewar.conf.Conf;
import shapewar.engine.calc.Pos;
import shapewar.engine.intefac.Regedit;
import shapewar.engine.model.abst.Model;
import shapewar.engine.model.abst.ModelAdapter;
import shapewar.engine.presenter.Presenter;
import shapewar.view.myview.MyView;

public class PointView extends MyView {
	public float x,y;
	public int alpha;
	private Model shape = getModel();
	private int t = 6;
	private boolean hide = false;
	
	public PointView(Presenter pst) {
		super(pst, new ModelAdapter(pst,-1,-10000,-10000,Conf.point_view_radium,Conf.depth_pointView){
			@Override
			public void init() {
				pst.regist(this,Regedit.IView);
			}
			
			@Override
			public void destory() {
				pst.registoff(this,Regedit.IView);
			}
			
//			@Override
//			public void resize() {
//				getView().resize();
//				this.r = EngineConf.point_view_radium;
//			}
		});
		
	}
	
	public void init() {
		pst.bridge.addView(this);
		shape.init();
	}
	
	public void destory(){
		pst.bridge.removeView(this);
		shape.destory();
	}
	
	public void touched(float x,float y){
		shape._x = x;
		shape._y = y;
		t = 4;
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		if(hide)return;
		t++;
		alpha = 1000/t;
		if(alpha<5)return;
		paint.setColor(Color.WHITE);
		paint.setAlpha(alpha);
		Pos pos = getRelativePos();
		canvas.drawCircle(pos.x, pos.y, shape.r * rate, paint);
	}
	
	public void hide(boolean bo){
		this.hide  = bo;
	}
	
}
